package leetcode.jianzhioffer;

import java.util.Arrays;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-11-01 14:33
 **/
public class JianZhiOffer57 {

    public int[] twoSum(int[] nums, int target) {
        int slow = 0;
        int fast = nums.length - 1;
        while (slow < fast) {
            while (nums[slow] + nums[fast] > target) {
                fast--;
            }
            while (nums[slow] + nums[fast] < target) {
                slow++;
            }
            if (nums[slow] + nums[fast] == target) {
                break;
            }
        }
        return new int[]{nums[slow], nums[fast]};
    }

}
